/**
 * Copyright (C) 2025 ROKAE (Beijing) Technology Co., LTD.
 * All Rights Reserved.
 *
 * Information in this file is the intellectual property of Rokae Technology Co., Ltd,
 * And may contains trade secrets that must be stored and viewed confidentially.
 *
 * @file InspireRobotsWidget.h
 * @brief 插件主界面
 */
#ifndef INSPIREROBOTSWIDGET_H
#define INSPIREROBOTSWIDGET_H

#include <QWidget>
#include <QIntValidator>
#include <QThread>
#include <QThreadPool>

#include "log/logmanager.h"
#include "interface/interfacemanager.h"
#include "JsonWorker.h"
#include "StatusPoller.h"

namespace Ui {
class InspireRobotsWidget;
}

class InspireRobotsWidget : public QWidget
{
    Q_OBJECT

public:
    explicit InspireRobotsWidget(QWidget *parent = nullptr);
    ~InspireRobotsWidget();

    void sendRequest(const QJsonObject &requestJson, std::function<void(QJsonArray)> callback);

private slots:
    /**
    * @brief 初始化按钮点击槽函数
    * 向设备发送设置ID命令作为初始化校验，成功后使能控制按钮和输入框
    */
    void on_pushButton_init_clicked();

    void on_pushButton_run_clicked();

    /**
    * @brief 重载 Qt 的事件函数
    * 让 InspireRobotsWidget 类知道 它是否当前显示在界面上
    * 界面展示时触发
    */
    void showEvent(QShowEvent*) override;

    /**
    * @brief 重载 Qt 的事件函数
    * 让 InspireRobotsWidget 类知道 它是否当前显示在界面上
    * 界面隐藏时触发
    */
    void hideEvent(QHideEvent*) override;


    void on_pushButton_setForce_clicked();

    void on_pushButton_setSpeed_clicked();

private:
    Ui::InspireRobotsWidget *ui;
    bool m_is_init;
    int m_device_id;
    StatusPoller* m_poller;
    QThread* m_polling_thread;
};

#endif // INSPIREROBOTSWIDGET_H
